From: Ignacy KuchciƄski Date: Tue, 2 Dec 2025 23:51:44 +0000 (+0100) Subject: authPrompt: Add ability to block authentication X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~39^2~1^2~80 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=3a481fa5c93139e7d353a5a5eeb5d7e737e89cbc;p=gnome-shell.git authPrompt: Add ability to block authentication Make it possible to prevent the user from using the authentication prompt, by showing the parental controls shield instead of the password entry. Part-of: --- diff --git a/data/theme/gnome-shell-sass/widgets/_login-lock.scss b/data/theme/gnome-shell-sass/widgets/_login-lock.scss index b661e93c8..d11d7224b 100644 --- a/data/theme/gnome-shell-sass/widgets/_login-lock.scss +++ b/data/theme/gnome-shell-sass/widgets/_login-lock.scss @@ -258,6 +258,21 @@ $_gdm_dialog_width: 25em; } } +// Parental controls +.parental-controls-shield { + spacing: 0.75em; + + .parental-controls-shield-title { + margin-top: 0.6em; + @extend %title_4; + text-align: center; + } + + .parental-controls-shield-description { + text-align: center; + } +} + // Notifications #unlockDialogNotifications { > .vhandle, > .hhandle { diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js index 2ad29b0e8..4a9e4f67b 100644 --- a/js/gdm/authPrompt.js +++ b/js/gdm/authPrompt.js @@ -17,6 +17,33 @@ import {wiggle} from '../misc/animationUtils.js'; const DEFAULT_BUTTON_WELL_ICON_SIZE = 16; const DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1000; + +// A widget displayed instead of the unlock prompt +// when parental controls session limits are reached +const ParentalControlsShield = GObject.registerClass( +class ParentalControlsShield extends St.BoxLayout { + _init() { + super._init({ + style_class: 'parental-controls-shield', + orientation: Clutter.Orientation.VERTICAL, + x_align: Clutter.ActorAlign.CENTER, + }); + + this._titleLabel = new St.Label({ + style_class: 'parental-controls-shield-title', + text: _('Screen Time Limit Reached'), + }); + this.add_child(this._titleLabel); + + this._descriptionLabel = new St.Label({ + style_class: 'parental-controls-shield-description', + text: _('Daily limit for screen time on this device has been reached. Resume tomorrow.'), + }); + this._descriptionLabel.clutter_text.line_wrap = true; + this.add_child(this._descriptionLabel); + } +}); + export const DEFAULT_BUTTON_WELL_ANIMATION_TIME = 300; export const MESSAGE_FADE_OUT_ANIMATION_TIME = 500; @@ -102,6 +129,7 @@ export const AuthPrompt = GObject.registerClass({ x_expand: true, }); this.add_child(this._inputWell); + this._mainContent = this._inputWell; this._hasCancelButton = this._mode === AuthPromptMode.UNLOCK_OR_LOG_IN; @@ -699,6 +727,25 @@ export const AuthPrompt = GObject.registerClass({ this._entry.clutter_text.insert_unichar(unichar); } + /* + * Set whether to block the authentication with the parental controls shield. + * + * @param {boolean} shouldBlock Whether to block the authentication + */ + setAuthBlocked(shouldBlock) { + if (!this._parentalControlsShield) + this._parentalControlsShield = new ParentalControlsShield(); + + const newMainContent = shouldBlock + ? this._parentalControlsShield + : this._inputWell; + + if (newMainContent !== this._mainContent) { + this.replace_child(this._mainContent, newMainContent); + this._mainContent = newMainContent; + } + } + begin(params) { params = Params.parse(params, { userName: null,